/**
 * 零件平台---修改设计的JS文件
 */

$(document).ready(function(){
	rightFormSubmit();//右侧细节设置修改提交
});

function getPartList(partstype,partsName,carid){
     //$("#loading").showLoading(); 
	  $.ajax({  
	        type : "POST",  
	        url : CONTEXT_PATH+'front/partDesign/getPartList?partsType='+partstype+'&partsName='+partsName+'&carid='+carid,  
	        dataType : "json",  
	        cache : false,  
	        async : false,  
	        success : function(data) {  
                $(".left-twoImgList.listImgBox").empty();
                
                for(i=0;i<data.length;i++){
                    $(".left-twoImgList.listImgBox").append(
        					"<div class='left-twoImgBlock leftImgBlock "+(data.id==$("#partsNo").val()? 'activeImg':'')+"'>"+
        					"<div class='left-twoImgBox'><img src='"+FILESERVER_PATH+"?id="+data[i].twoDid+"'/></div>"+
        					"<div class='left-oneImgName'>"+data[i].partsName+"</div>"+
        				        "<input type='hidden' value="+JSON.stringify(data[i])+">"+
        				    "</div>");
                }
                imgSelectControl();
                $("#partstype").val(partstype);
                //$('#loading').hideLoading();
                
	        }  
	    }); 
	
}

function rightFormSubmit(){
	$("#rightformSubmit").click(function(){
		$("#partModifyModal").modal('show');
	});
	
}

var isSubmit = false; 

function submitForm(){
	   if (isSubmit) {  
	        return  
	   }  
	                  
	  var  url=CONTEXT_PATH+'front/partDesign/updatePartDesign';
	   	   
	   isSubmit = true;  
	   
	   $('#partDesignform').ajaxSubmit({
		    dataType: "json",  
		    url: url,
		    type : "POST",
		    success: function(data) {  
                if(data.result){
                	window.location.href= CONTEXT_PATH+'front/partDesign/partDesign_list';
                	 isSubmit = false;  
                     
                	
                }else{
                	alert("修改失败！");
                }
 
		    }   
		  
	  });  
}

function download(designid){
        
	    $("#designid").val(designid);
	    $("input[name='chose']").prop("checked",false);
		$("#loadModal").modal('show');
	 
}

function submitDownload(){
	
	if ($("input[name='chose']:checked").length!=0) {
		$("#downloadForm").submit();
		$("#loadModal").modal('hide');
	}else{
		jAlert("请先至少选中一个","提示");
	}
	
}
